
local form_validation = require("config.form_validation");
local form_validate = require("mvc.form.form_validate");


local function add(req, resp)
	local context = {};
	context["message"] = "hades";
	local a = req.get_param("a");
	local a = req.get_param("b");
	return "success", context;
end


local function do_add(req, resp)
	
	local params = req.get_params();
	local validate_result = form_validate.do_validate(form_validation.form_name_1, params);

	if validate_result.success ~= true then
		return "fail", validate_result;
	end
	
	return "success", form;

end


local function update(req, resp)
	ngx.say("Hello lua mvc update");
	return "success";
end

local function do_update(req, resp)
	--业务逻辑
	local template_context = {};
	template_context["success"] = true;
	template_context["code"] = 1;
	template_context["message"] = "更新成功";
	return template_context
end

local function edit(req, resp)
	return "to_add";
end

local function reg(req, resp)
	--resp.out("reg");
	return "not_found";
end


local _M = {  
   add = add,
   do_add = do_add,
   update = update,
   do_update = do_update,
   edit = edit,
   reg = reg
}

return _M